package com.ggh.jinjilive.common;


import com.ggh.jinjilive.BaseApplication;
import com.ggh.jinjilive.mobile.UserMobile;

public class MerchantSession {
    private ISharedPreferences isp = null;

    private static MerchantSession instance;

    private UserMobile info = null;
    public static MerchantSession getInstance() {
        if (instance == null) {
            synchronized (MerchantSession.class) {
                instance = new MerchantSession();
            }
        }
        return instance;
    }

    private MerchantSession() {
        isp = ISharedPreferences.getInstance(BaseApplication.getInstance(), Constants.SYSTEM_SETTING);
    }


    /**
     * 用户数据
     * @return
     */
    public UserMobile getUser() {
        if (isLogin()) {
            info = new UserMobile();
            info.setUser_id(isp.getString("user_id",""));
            info.setNickname(isp.getString("nickname",""));
            info.setSex(isp.getInt("sex",0));
            info.setLevel(isp.getInt("level",0));
            info.setLevel_img(isp.getString("level_img",""));
            info.setMobile(isp.getString("mobile",""));
            info.setHead_portrait(isp.getString("head_portrait",""));
            info.setFocus_num(isp.getInt("focus_num",0));
            info.setFans_num(isp.getInt("fans_num",0));
            info.setIntroduce(isp.getString("introduce",""));
            info.setIs_family(isp.getInt("is_family",0));
            info.setBirthday(isp.getString("birthday",""));
            info.setLive_num(isp.getInt("live_num",0));
            info.setFamily_user_id(isp.getString("family_user_id", ""));
            info.setIs_anchor_auth(isp.getInt("is_anchor_auth", 0));
            info.setMsg_count(isp.getInt("msg_count", 0));
            info.setVip_video_status(isp.getInt("vip_video_status", 0));
            info.setVip_visitors_status(isp.getInt("vip_visitors_status", 0));
            info.setVip_area_status(isp.getInt("vip_area_status", 0));
            info.setVip_dazzle_status(isp.getInt("vip_dazzle_status", 0));
            info.setVip_private_status(isp.getInt("vip_private_status", 0));
            info.setLng(isp.getString("lng", ""));
            info.setLat(isp.getString("lat", ""));
            info.setProvince(isp.getString("province", ""));
            info.setCity(isp.getString("city", ""));
            info.setDistrict(isp.getString("district", ""));
            info.setHead_frame(isp.getString("head_frame", ""));
            info.setCar(isp.getString("car", ""));
            info.setIs_privacy(isp.getInt("is_privacy", 0));
            info.setIs_other(isp.getInt("is_other", 0));
            info.setB_img(isp.getString("b_img", ""));
            info.setImg(isp.getString("img", ""));
            info.setIs_map(isp.getInt("is_map", 0));
        }
        return info;
    }


    /**
     * 用户数据
     * @param user
     */
    public void setUser(UserMobile user) {
        setIsLogin(true);
        isp.putString("user_id", user.getUser_id());
        isp.putString("nickname",user.getNickname());
        isp.putInt("sex",0);
        isp.putInt("level",user.getLevel());
        isp.putString("level_img",user.getLevel_img());
        isp.putString("mobile",user.getMobile());
        isp.putString("head_portrait",user.getHead_portrait());
        isp.putInt("focus_num",user.getFocus_num());
        isp.putInt("fans_num",user.getFans_num());
        isp.putString("introduce",user.getIntroduce());
        isp.putInt("is_family",user.getIs_family());
        isp.putString("birthday",user.getBirthday());
        isp.putInt("live_num",user.getLive_num());
        isp.putString("family_user_id",user.getFamily_user_id());
        isp.putInt("is_anchor_auth",user.getIs_anchor_auth());
        isp.putInt("msg_count",user.getMsg_count());
        isp.putInt("vip_video_status",user.getVip_video_status());
        isp.putInt("vip_visitors_status",user.getVip_visitors_status());
        isp.putInt("vip_area_status",user.getVip_area_status());
        isp.putInt("vip_dazzle_status",user.getVip_dazzle_status());
        isp.putInt("vip_private_status",user.getVip_private_status());
        isp.putInt("msg_count",user.getMsg_count());
        isp.putString("lng", user.getLng());
        isp.putString("lat",user.getLat());
        isp.putString("province", user.getProvince());
        isp.putString("city",user.getCity());
        isp.putString("district", user.getDistrict());
        isp.putString("head_frame",user.getHead_frame());
        isp.putString("car", user.getCar());
        isp.putInt("is_privacy",user.getIs_privacy());
        isp.putInt("is_other",user.getIs_other());
        isp.putString("b_img", user.getB_img());
        isp.putString("img", user.getImg());
        isp.putInt("is_map",user.getIs_map());

    }




    public void setToken(String token){
        //token
        isp.putString("token", token);
    }

    public String getToken(){
        //token
        return isp.getString("token", "");
    }


    public boolean isLogin() {
        //标记登录成功
        return isp.getBoolean("AppIsLogin", false);
    }

    public void setIsLogin(boolean isLogin) {
        //标记登录成功
        isp.putBoolean("AppIsLogin", isLogin);
    }

    public void setMobile(String Mobile){
        //记录手机号
        isp.putString("Mobile",Mobile);
    }

    public String getMobile(){
        //获取记录手机号
        return isp.getString("Mobile","");
    }

    public void setPassword(String Password){
        //记录密码
        isp.putString("Password",Password);
    }

    public String getPassword(){
        //获取记录密码
        return isp.getString("Password","");
    }


    public void setPrivacy(boolean isPrivacy){
        //隐私协议
        isp.putBoolean("isPrivacy",isPrivacy);
    }

    public Boolean getPrivacy(){
        //隐私协议
        return isp.getBoolean("isPrivacy",false);
    }


    public void setSignTime(long SignTime){
        //当前时间
        isp.putLong("SignTime", SignTime);
    }

    public long getSignTime(){
        //当前时间
        return isp.getLong("SignTime", 0L);
    }



    public void setLiveToken(String LiveToken){
        //直播LiveToken
        isp.putString("LiveToken",LiveToken);
    }

    public String getLiveToken(){
        //直播LiveToken
        return isp.getString("LiveToken","");
    }


    public void setLiveUserID(String LiveUserID){
        //直播UserID
        isp.putString("LiveUserID",LiveUserID);
    }

    public String getLiveUserID(){
        //直播UserID
        return isp.getString("LiveUserID","");
    }
}
